package com.qinglei.recoup.common.tenant;

import lombok.experimental.UtilityClass;

/**
 * @author syp
 * @date 2018/10/4
 * 租户工具类
 *
 */
@UtilityClass
public class TenantContextHolder {
	// 默认机构id
	public static final Integer DEFAULT_TENANT_ID = 1;
	// 默认院长id
	public static final Long DEFAULT_DEAN_ID = 1L;
	// 默认护士id
	public static final Long DEFAULT_NURSE_ID = 2L;


	private final ThreadLocal<Integer> THREAD_LOCAL_TENANT = new ThreadLocal<>();


	/**
	 * TTL 设置租户ID
	 *
	 * @param tenantId
	 */
	public void setTenantId(Integer tenantId) {
		THREAD_LOCAL_TENANT.set(tenantId);
	}

	/**
	 * 获取TTL中的租户ID
	 *
	 * @return
	 */
	public Integer getTenantId() {
		return THREAD_LOCAL_TENANT.get();
	}

	public void clear() {
		THREAD_LOCAL_TENANT.remove();
	}
}
